import {  ArticleDetail ,Comment} from "@/types/data"
import { ArticleDetailAction } from "@/types/store"

type State = {
  info: ArticleDetail
  comment: Comment
}

const initialState = {
  info: {},
  comments: {}
} as unknown as State

const article = (state = initialState, action: ArticleDetailAction) => {
  switch(action.type){
    case 'articleDetail/setArticleInfo':
    return {...state, info:action.payload}
    case 'articleDetail/saveComment':
    return { ...state,comment: action.payload}
    default:
    return state
    }
    
}

export default article

